<?php
    require_once(MODEL_PATH.'/CMS/Base.php');
    //require_once(LIB_PATH.'/HTMLComponent.php');
    
    class Model_CMS_Mailer extends MODEL_CMS_Base{
    
        function __construct(){
        }
        
        
        
        function email_from_webmaster($subject, $body, $to_email, $to_mail){
        	#$from_email = 'admin@itrial.hk';
        	$from_email = 'imore_webmaster@nmg.hk';
        	$from_name = 'itrial by iMore';
        	
        	$reply_to_email = 'imore_enq@nmg.com.hk';
        	
        	// remove after testing
        	
          #echo "Original Email to $to_mail\n";
        	//$to_email = 'clifftse@nmg.com.hk'; # override for testing
        	#$to_email = 'loulu@nmg.com.hk';
        	
        	
        	
        	$this->sendmail($subject, $body, $from_email, $from_name, $reply_to_email, $to_email, $to_name);
        }	                                             
        	                                            

	function sendmail($subject, $body, $from_email, $from_name, $reply_to_email, $to_email, $to_name){

		//echo "$subject, $body, $from_email, $from_name, $reply_to_email, $to_email, $to_name";
		//exit;
		//include "class-phpmailer.php"; 
		//include "../../class-phpmailer.php";
		require_once "/home/itrial/lib/Vendor/Mail/class-phpmailer.php";
		
		$mail = new PHPMailer();  
		// $mail->IsSendmail();		
		//Start: Temp remark
		
		$mail->IsSMTP();							// smtp
		$mail->Host     = "nmgmail01.nmg.hk";		// SMTP server
		$mail->SMTPAuth = false;					// 
		//End: Temp remark
		
		//$mail->Username = "";    // username
		//$mail->Password = "";    // password
		$mail->From     = $from_email;
		
		if ($from_name != ''){
		  $mail->FromName = $from_name;
	  }
	  
	  if ($reply_to_email != ''){
		  $mail->AddReplyTo($reply_to_email);	
	  }
	  
		  $mail->AddAddress($to_email, $to_name);
    
    
	 
		$mail->IsHTML(true);              
		$mail->Subject  = $subject;		//	subject
		$mail->Body     = $body;			//	content

		return $mail->Send();  
	}
       
       
       
      
    }
    
    ?>